//
// Created by vista on 2017/12/27.
//

//
// Created by vista on 2017/12/24.
//


#include <vector>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <iostream>
#include <stack>
#include <set>
using namespace std;

class Solution {
public:

    int removeDuplicates(vector<int>& nums) {
        if(nums.empty())
            return 0;
        int count = 1;
        int last = *nums.begin();
        auto itr = nums.begin();
        auto eitr = nums.end() ;

        for ( ++itr ; itr != eitr; eitr = nums.end()) {
            if(*itr != last){
                ++count;
                last = *itr;
                ++itr;
            }else{
                itr = nums.erase(itr);
            }
        }
        return count;
    }
};

int main(){

    Solution solution;

    __uint64_t timebegin =  clock_gettime_nsec_np(CLOCK_REALTIME);

    vector<int> nums;
//    for (int i = 0; i < 100; ++i) {
//        nums.push_back(i);
//    }

    nums.push_back(1);
//    nums.push_back(1);
//    nums.push_back(2);

    cout << solution.removeDuplicates(nums) << endl;

    __uint64_t timeend =  clock_gettime_nsec_np(CLOCK_REALTIME);

    cout << (timeend - timebegin) / 1000000.0 << endl;

    return 0;

}